package com.woniu.info.controller;


import com.woniu.entity.PageResult;
import com.woniu.entity.Result;
import com.woniu.info.entity.MessageDTO;
import com.woniu.info.pojo.Message;
import com.woniu.info.service.IMessageService;
import io.swagger.annotations.ApiOperation;
import org.bouncycastle.asn1.dvcs.ServiceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 消息通知表 前端控制器
 * </p>
 *
 * @author LiFangyu
 * @since 2023-02-15
 */
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private IMessageService messageService;

    // 添加服务类别
    @ApiOperation("添加消息")
    @PostMapping("/addMessage")
    public Result<ServiceType> addMessage(@RequestBody Message message){
        messageService.addMessage(message);
        return Result.ok();
    }

    // 删除服务类别
    @ApiOperation("删除消息")
    @DeleteMapping("/deleteMessage/{id}")
    public Result<Message> deleteMessage(@PathVariable String id){
        messageService.deleteMessage(id);
        return Result.ok();
    }

    // 修改服务类型
    @ApiOperation("修改消息")
    @PutMapping("/updateMessage")
    public Result<Message> updateMessage(@RequestBody Message message){
        messageService.updateMessage(message);
        return Result.ok();
    }

    // 查询服务类型
    @ApiOperation("查询消息")
    @PostMapping("/queryMessage/{currentPage}/{pageSize}")
    public Result<PageResult<Message>> queryMessage(@PathVariable Integer currentPage,
                                                            @PathVariable Integer pageSize,
                                                            MessageDTO messageDTO){
        PageResult<Message> pageResult = messageService.queryMessage(currentPage,pageSize,messageDTO);
        return Result.ok(pageResult);
    }


}
